home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / game / patch / pxhd.lha / ProjectX / src / pxhdsrc / pxhd.asm < prev   
Assembly Source File  |  1997-08-12  |  5KB  |  345 lines

  1. ; *** Project-X Hard Disk Loader V1.3
  2. ; *** Written by Jean-François Fabre
  3.  
  4.  
  5.     include    "/lib/libs.i"
  6.     include    "/lib/macros.i"
  7.     include    "/lib/refs.i"
  8.  
  9.     HD_PARAMS    "ProjectX.d","CON:20/20/350/200/Project-X HD Loader",STD_DISK_SIZE,4
  10.  
  11. _loader:
  12.     move.l    D0,trainer
  13.     move.l    D1,noosswap
  14.  
  15.     Mac_printf    "Project-X HD Loader V1.3c"
  16.     Mac_printf    "Coded by Jean-François Fabre © 1997"
  17.  
  18.     tst.l    D0
  19.     beq    skip$
  20.  
  21. ;    NEWLINE
  22. ;    Mac_printf    "Trainer activated"
  23. skip$
  24.     JSRABS    LoadDisks
  25.     JSRABS    TransfRoutines
  26.  
  27.     bsr    GetVersion
  28.  
  29.     ; *** Tries to allocate memory for extension
  30.  
  31.     move.l    #MEMF_FAST,D1
  32.     move.l    _SysBase,A6
  33.     JSRLIB    AvailMem
  34.     move.l    D0,D6
  35.  
  36.     cmp.l    #$200000,D6    ; more than 2 mb of fastmem available
  37.     bcs    lowmem$        ; no
  38.  
  39.     move.l    #$100000,D0
  40.     JSRABS    AllocExtMem
  41.     move.l    D0,ExtBase
  42.     bne    onemeg$
  43.  
  44. lowmem$
  45.     move.l    #$80000,D0
  46.     JSRABS    AllocExtMem
  47.     move.l    D0,ExtBase
  48.     beq    MemErr
  49.     bra    cont$
  50. onemeg$
  51.     add.l    #$80000,D0
  52.     move.l    D0,ExtBase2
  53.     beq    MemErr    
  54. cont$
  55.  
  56.     moveq.l    #0,D0
  57.     move.l    #CACRF_CopyBack,D1
  58.     JSRABS    Degrade
  59.  
  60. ;    WAIT_LMB
  61.  
  62.     RELOCATE    version
  63.     RELOCATE    ExtBase
  64.     RELOCATE    ExtBase2
  65.  
  66.     GO_SUPERVISOR
  67.     SAVE_OSDATA    $80000
  68.  
  69.     GETUSRADDR    BootGame
  70.     move.l    D0,A0
  71.     jmp    (A0)
  72.  
  73.  
  74. GetVersion
  75.     moveq.l    #0,D0
  76.     moveq.l    #$C,D2    ; offset
  77.     moveq.l    #4,D1    ; length
  78.     lea    versiontag(pc),A0
  79.     JSRGEN    ReadDiskPart
  80.  
  81.     move.l    (A0),D0
  82.     cmp.l    #$2F09203C,D0
  83.     bne    notv1$
  84.  
  85.     move.l    #1,version
  86.     rts
  87.  
  88. notv1$
  89.     cmp.l    #$33FC0020,D0
  90.     bne    notv2$
  91.  
  92.     move.l    #2,version
  93.     rts
  94.  
  95. notv2$
  96.     Mac_printf    "** Unsupported Project-X version. Contact the author"
  97.     JMPABS    CloseAll
  98.  
  99.  
  100. MemErr:
  101.     Mac_printf    "** Not enough memory to run Project-X"
  102.     JMPABS    CloseAll
  103.  
  104. versiontag:
  105.     dc.l    0,0
  106.  
  107.  
  108. _UserPatchRoutines:
  109. BootGame:
  110.     ; **** boot stuff and patch
  111.  
  112.     JSRGEN    InitTrackDisk
  113.     lea    $70000,A3
  114.  
  115.     MOVE.L    A3,40(A1)        ;2C: 234B0028
  116.     MOVE.L    #$00001000,36(A1)    ;30: 237C000010000024
  117.     MOVE.L    #$0006E600,44(A1)    ;38: 237C0006E600002C
  118.     MOVE    #$0002,28(A1)        ;40: 337C0002001C
  119.     JSRGEN    TrackLoad
  120.     
  121.     move.l    #$400,$144(A3)
  122.     move.l    ExtBase(pc),$140(A3)
  123.     move.l    ExtBase2(pc),$13C(A3)
  124.     GETUSRADDR    PatchLoader1
  125.     move.l    D0,$138(A3)
  126.  
  127.     move.l    version(pc),D0
  128.     cmp.l    #1,D0
  129.     bne    3$
  130.     lea    $8A8(A3),A4
  131.     bra    verok$
  132. 3$
  133.     cmp.l    #2,D0
  134.     bne    2$
  135.     lea    $89A(A3),A4
  136.     bra    verok$
  137.  
  138. 2$
  139. verok$
  140.     PATCHUSRJMP    (A4),ReadSectors1
  141.  
  142.     PATCHUSRJMP    ($E6,A3),PatchLoader1
  143.     
  144.     lea    $80000,A7
  145.     JSRGEN    FlushCachesHard
  146.  
  147.     JMP    $70(A3)
  148.  
  149.  
  150. PatchLoader1:
  151.     STORE_REGS
  152.  
  153.     move.l    ExtBase(pc),A0
  154.  
  155.     move.l    version(pc),D0
  156.     cmp.l    #2,D0
  157.     beq    v2$
  158.  
  159.     PATCHUSRJMP    ($46B4,A0),ReadSectors2
  160.     PATCHUSRJMP    ($3CFE,A0),PatchAfterATN
  161.     lea    hiscore_offset(pc),A1
  162.     move.l    #$57CE,(A1)
  163.     bra    vcom$
  164.  
  165. v2$
  166.     PATCHUSRJMP    ($465E,A0),ReadSectors2
  167.     PATCHUSRJMP    ($3CA8,A0),PatchAfterATN
  168.  
  169.     lea    hiscore_offset(pc),A1
  170.     move.l    #$5778,(A1)
  171.  
  172. vcom$
  173.     ; *** read high scores
  174.  
  175.     move.l    noosswap(pc),D4
  176.     bne    skip$
  177.  
  178.     move.l    hiscore_offset(pc),A1
  179.     add.l    A0,A1
  180.     lea    hiscname(pc),A0
  181.     moveq.l    #0,D0
  182.     move.l    #$A0,D1
  183.     JSRGEN    ReadFileHD
  184.  
  185. skip$    
  186.  
  187.     JSRGEN    FlushCachesHard
  188.     RESTORE_REGS
  189.     move.l    $7013C,D0
  190.     jmp    (A0)
  191.  
  192.  
  193. PatchAfterATN:
  194.     STORE_REGS
  195.  
  196.     move.l    ExtBase(pc),A0
  197.  
  198.     ; *** different offsets depending on the version
  199.  
  200.     move.l    version(pc),D0
  201.     cmp.l    #1,D0
  202.     bne    nopkb_v1$
  203.  
  204.     ; *** test quit key during game
  205.  
  206.     move.l    A0,A2
  207.     add.l    #$1FEE6,A2
  208.     cmp.w    #$1039,(A2)
  209.     bne    kb1$
  210.  
  211.     PATCHUSRJSR    (A2),kbint
  212.  
  213.     ; *** test quit key during menu
  214. kb1$
  215.     cmp.w    #$1039,$1D3E(A0)
  216.     bne    nopkb_v1$
  217.  
  218.     PATCHUSRJSR    ($1D3E,A0),kbint
  219.  
  220. nopkb_v1$
  221.     cmp.l    #2,version
  222.     bne    nopkb_v2$
  223.     
  224.     ; *** test quit key during game
  225.  
  226.     move.l    A0,A2
  227.     add.l    #$1FE90,A2
  228.     cmp.w    #$1039,(A2)
  229.     bne    kb2$
  230.  
  231.     PATCHUSRJSR    (A2),kbint
  232.  
  233.     ; *** test quit key during menu
  234.  
  235. kb2$
  236.     cmp.w    #$1039,$1CE8(A0)
  237.     bne    nopkb_v2$
  238.  
  239.     PATCHUSRJSR    ($1CE8,A0),kbint
  240. nopkb_v2$
  241.  
  242.     ; *** common to both versions
  243.  
  244.     cmp.w    #$41F9,$408.W
  245.     bne    noppr$
  246.  
  247.     move.w    #$4E75,$408.W
  248. noppr$
  249.  
  250.     cmp.w    #$2E28,$1984.W
  251.     bne    noplc$
  252.  
  253.     move.l    #$7E024E71,$1984.W
  254.  
  255. noplc$
  256.     JSRGEN    ResetSprites
  257.     JSRGEN    FlushCachesHard
  258.  
  259.     RESTORE_REGS
  260.     movem.l    (A7)+,D2-D5/A2-A4
  261.     tst.l    D0
  262.     RTS
  263.  
  264.  
  265.  
  266. kbint:
  267.     move.b    $BFEC01,D0
  268.     move.l    D0,-(sp)
  269.     not.b    D0
  270.     ror.b    #1,D0
  271.     cmp.b    #$5F,D0
  272.     bne    noquit$
  273.     JSRGEN    InGameExit
  274. noquit$
  275.     move.l    (sp)+,D0
  276.     rts
  277.  
  278. ReadSectors1:
  279. ReadSectors2:
  280.     STORE_REGS
  281.  
  282.     cmp.b    #1,D3        ; write?
  283.     beq    write$
  284.  
  285.     tst.w    D1
  286.     beq    exit$
  287.  
  288.     JSRGEN    ReadRobSectors
  289. exit$
  290.     RESTORE_REGS
  291.     moveq.l    #0,D0
  292.     tst.l    D0
  293.     rts
  294.  
  295. write$
  296.     ; *** read high scores
  297.  
  298.     move.l    ExtBase(pc),A1
  299.     add.l    hiscore_offset(pc),A1
  300.     cmp.l    A1,A0
  301.     bne    exit$
  302.  
  303.     bsr    WriteScores
  304.  
  305.     bra    exit$
  306.  
  307. WriteScores:
  308.     STORE_REGS
  309.     tst.l    noosswap
  310.     bne    skip$
  311.  
  312.     move.l    ExtBase(pc),A1
  313.     add.l    hiscore_offset(pc),A1
  314.     lea    hiscname(pc),A0
  315.     moveq.l    #0,D0
  316.     move.l    #$A0,D1
  317.     JSRGEN    WriteFileHD
  318. skip$
  319.     RESTORE_REGS
  320.     rts
  321.  
  322.  
  323.  
  324. _user_pbuffer:
  325.     dc.l    0
  326. _general_pbuffer:
  327.     dc.l    0
  328. ExtBase:
  329.     dc.l    0
  330. ExtBase2:
  331.     dc.l    0
  332. trainer:
  333.     dc.l    0
  334. noosswap:
  335.     dc.l    0
  336. version:
  337.     dc.l    0
  338. hiscore_offset:
  339.     dc.l    0
  340. hiscname:
  341.     dc.b    "px.high",0
  342.     even
  343. _EndUserPatchRoutines:
  344.  
  345.